package {
	import flash.display.MovieClip;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.system.Capabilities;

	public class np extends MovieClip
	{
		public static var debug:Debugger;
		public static var menu:MenuBar;
		
		public function Init():void {
			var xres:uint;
			var yres:uint;
			var dbgwidth:uint;
			/* Auto-select video resolution for testing */
			switch (flash.system.Capabilities.screenResolutionX) { /* only my machines so far */
				case 1024: xres = 800; yres = 600; dbgwidth = 100; break;
				case 1280: xres = 800; yres = 600; dbgwidth = 200; break;
				case 1600: xres = 1024; yres = 768; dbgwidth = 200; break;					
				case 1920: xres = 1600; yres = 768; dbgwidth = 500; break;
				default: xres = 800; yres = 600; dbgwidth = 200; break; /* video res. defaults */
			}
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.stageFocusRect = false;
			stage.showDefaultContextMenu = false;
			//debug = new Debugger(xres+5, 0, dbgwidth, yres);
			debug = new Debugger(0, 0, xres, yres);
			stage.addChild(debug);			
			menu = new MenuBar(0,yres+5,xres, 30);
			menu.addItem("Test");
			stage.addChild(menu);
		}
		
		public function np()
		{
			Init();
			debug.print("Starting!");
			var pdbtest:Structure;
			
			Flow.Ord(function():void {
				Loader.Load("samples/1B41.pdb"); // "samples/ache_vr_hi6.pdb"
			});
			
			Flow.Ord(function():void {
				pdbtest = Reader.ReadPDB(Loader.buffer);
				debug.print("PDB Done!");
				
				Loader.Load("data/BLOSUM62.txt");
				//Loader.Load("data/TEST.txt");
				//Loader.Load("data/IDENTITY.txt");
				//Loader.Load("data/MATCH.txt");
			});
			
			Flow.Ord(function():void {
				Compute.LoadSimMatrix(Loader.buffer); /* Default matrix for NW sequence alignment. */
				
				Compute.AlignTester();
				
				debug.print("F,K = " + Compute.SimMatrix["F"]["K"]);
				debug.print("E,E = " + Compute.SimMatrix["E"]["E"]);
				
				debug.print("atom test...");
				/*
				var a:Atom = new Atom({"atype":"atom", "serial":1, "name":"C", "altLoc":"", "resName":"LYS",
		 				   "chainID":"A", "resSeq":1, "iCode":"",
		 				   "x":1000, "y":2000, "z":3000, "occupancy":1.0, "tempFactor":1.0, "element":"C", "charge":""}, this);
		 				   
				debug.print("atom ok...");
				*/
				//Flow.Next();
			});
			
			//Flow.Ord(function():void {
			//});
		}
	}
}
